﻿using System;

namespace MyFirstHomework
{
    /// <summary>
    /// 利用*输出四种形状
    /// </summary>
    class Program
    {
        private const int LinesCount = 5;
        static void Main(string[] args)
        {
            Console.Clear();
            RightAngledTriangle();//实心直角三角形
            IsoscelesTriangle();//实心等腰三角形
            HollowIsoscelesTriangle();//空心等腰三角形
            Hollowdiamond();//空心菱形
            Console.ReadKey();
        }
        /// <summary>
        /// 输出实心直角三角形
        /// </summary>
        static void RightAngledTriangle()
        {
            for (int i = 1; i <= LinesCount; i++)
            {
                Console.WriteLine(new String('*', i));
            }
        }
        /// <summary>
        /// 输出实心等腰三角形
        /// </summary>
        static void IsoscelesTriangle()
        {
            for (int i = 0; i < LinesCount; i++)
            {
                for (int k = 0; k < LinesCount - i; k++)
                {
                    Console.Write(" ");
                }
                for (int j = 0; j < 2 * i - 1; j++)
                {
                    Console.Write("*");
                }
                Console.Write("\n");
            }
        }
        /// <summary>
        /// 输出空心等腰三角形
        /// </summary>
        static void HollowIsoscelesTriangle()
        {
            for (int i = 0, j; i < LinesCount; i++)
            {
                for (j = 0; j < LinesCount - i - 1; j++)
                    Console.Write(" ");
                for (j = 0; j < 2 * i + 1; j++)
                {
                    if (i == LinesCount - 1) Console.Write("*");
                    else if (j == 0 || j == 2 * i)
                        Console.Write("*");
                    else
                        Console.Write(" ");
                }
                Console.Write("\n");
            }
        }
        /// <summary>
        /// 输出空心菱形
        /// </summary>
        static void Hollowdiamond()
        {
            //上半部分输出LinesCount行
            for (int i = 1; i <= LinesCount; i++)
            {
                for (int j = 1; j <= LinesCount + i - 1; j++)
                {
                    if ((j != LinesCount - i + 1) && (j != LinesCount + i - 1))
                        Console.Write(" ");
                    else
                        Console.Write("*");
                }
                Console.Write("\n");
            }

            //下半部分输出LinesCount-1行
            for (int i = LinesCount - 1; i >= 1; i--)
            {
                for (int j = LinesCount * 2 - 1; j >= 1; j--)
                {
                    if ((j != LinesCount + i - 1) && (j != LinesCount - i + 1))
                        Console.Write(" ");
                    else
                        Console.Write("*");
                }
                Console.Write("\n");
            }
        }
    }
}
